/**
 * Project Name:YCApiServer-Api
 * File Name:PushController.java
 * Package Name:com.yc.music.controller.Api.push
 * Date:2016年9月10日 下午4:08:24
 * Copyright (c) 2016 
 *
 */
package com.yc.music.controller.Api.push;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yc.music.common.context.YcContext;
import com.yc.music.service.server22.PushService;

/**
 * 
 * ClassName: PushController <br/>
 * Function: 提供触发接口,内网数据不经过加密. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2016年9月10日 下午4:08:24 <br/>
 *
 * @author qinhaiguan
 * @version v2.2
 */
@Controller
@RequestMapping("/pub/push")
public class PushController {

	private static Logger logger = Logger.getLogger(PushController.class);
	
	@Autowired
	private PushService pushService;
	

	@ResponseBody
	@RequestMapping(value="/addtosonglist22", method = RequestMethod.POST, produces = "application/json")
	public Map<String,Object> addToSonglist(@RequestParam(value="uid",required=false) Long uid,
			@RequestParam(value="songListName",required=false)  String songListName,
			@RequestParam(value="workid",required=false) Long workid) {
		
		Map<String,Object> result  = new HashMap<String,Object>();
		try {
			pushService.addWorkToSonglist(uid,songListName,workid,result);
			
		} catch (Exception e) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE, YcContext.SYS_ERROR_MSG);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			logger.error(e);
		}
		return result;
	}
	
	@ResponseBody
	@RequestMapping(value="/addCooperateworkTosonglist23", method = RequestMethod.POST, produces = "application/json")
	public Map<String,Object> addCooperateworkTosonglist23(@RequestParam(value="wuid",required=false) Long wuid,
			@RequestParam(value="luid",required=false) Long luid,
			@RequestParam(value="songListName",required=false)  String songListName,
			@RequestParam(value="workid",required=false) Long workid) {
		
		Map<String,Object> result  = new HashMap<String,Object>();
		try {
			logger.info("推荐合作歌曲到歌单信息：wuid="+wuid+",luid="+luid+",songListName="+songListName+",workid="+workid);
			pushService.addCooperateworkTosonglist23(wuid,luid,songListName,workid,result);
			
		} catch (Exception e) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE, YcContext.SYS_ERROR_MSG);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			logger.error(e);
		}
		return result;
	}
	

	@ResponseBody
	@RequestMapping(value="/recommedtoindex22", method = RequestMethod.POST, produces = "application/json")
	public Map<String,Object> recommedToIndex(
			@RequestParam(value="uid",required=false) Long uid,
			@RequestParam(value="workid",required=false) Long workid,
			@RequestParam(value="type",required=false) Integer type) {
		
		
		Map<String,Object> result  = new HashMap<String,Object>();
		try {
			pushService.recommedWorkToIndex(uid,workid,type,result);
		} catch (Exception e) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE, YcContext.SYS_ERROR_MSG);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			logger.error(e);
		}
		return result;
	}
	
	@ResponseBody
	@RequestMapping(value="/recommedCooperatewookToindex23", method = RequestMethod.POST, produces = "application/json")
	public Map<String,Object> recommedCooperatewookToindex23(
			@RequestParam(value="wuid",required=false) Long wuid,
			@RequestParam(value="luid",required=false) Long luid,
			@RequestParam(value="workid",required=false) Long workid,
			@RequestParam(value="type",required=false) Integer type) {
		
		
		Map<String,Object> result  = new HashMap<String,Object>();
		try {
			logger.info("推荐合作歌曲到首页信息：wuid="+wuid+",luid="+luid+",workid="+workid+",type="+type);
			pushService.recommedCooperatewookToindex23(wuid,luid,workid,type,result);
		} catch (Exception e) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE, YcContext.SYS_ERROR_MSG);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			logger.error(e);
		}
		return result;
	}
	
	
	@ResponseBody
	@RequestMapping(value="/newactivity22", method = RequestMethod.POST, produces = "application/json")
	public Map<String,Object> newActivity(
			@RequestParam(value="title",required=false) String title,
			@RequestParam(value="aid",required=false)Long aid) {
		
		Map<String,Object> result  = new HashMap<String,Object>();
		try {
			pushService.newActivity(aid,title,result);
		} catch (Exception e) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE, YcContext.SYS_ERROR_MSG);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			logger.error(e);
		}
		return result;
	}
	
	@ResponseBody
	@RequestMapping(value="/activityfinish22", method = RequestMethod.POST, produces = "application/json")
	public Map<String,Object> activityFinish(
			@RequestParam(value="title",required=false) String title,
			@RequestParam(value="aid",required=false)Long aid) {
		
		Map<String,Object> result  = new HashMap<String,Object>();
		try {
			pushService.activityFinish(aid,title, result);
		} catch (Exception e) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE, YcContext.SYS_ERROR_MSG);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			logger.error(e);
		}
		return result;
	}
	
	
	@ResponseBody
	@RequestMapping(value="/copyrightSuccess22", method = RequestMethod.POST, produces = "application/json")
	public Map<String,Object> copyrightSuccess22(
			@RequestParam(value="workid") Long workid,
			@RequestParam(value="type") Integer type,
			@RequestParam(value="ctype") Integer ctype,
			@RequestParam(value="uid")Long uid,
			@RequestParam(value="orderNo")String orderNo) {
		
		Map<String,Object> result  = new HashMap<String,Object>();
		try {
			logger.info("推送保权成功信息，传入参数：workid="+workid+",type="+type+",ctype="+ctype+",uid="+uid);
			pushService.copyrightSuccess(workid,uid,type,orderNo, result);
		} catch (Exception e) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE, YcContext.SYS_ERROR_MSG);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			logger.error(e);
		}
		return result;
	}
	
	
	@ResponseBody
	@RequestMapping(value="/copyrightFail22", method = RequestMethod.POST, produces = "application/json")
	public Map<String,Object> copyrightFail22(
			@RequestParam(value="workid") Long workid,
			@RequestParam(value="type") Integer type,
			@RequestParam(value="ctype") Integer ctype,
			@RequestParam(value="uid")Long uid,
			@RequestParam(value="orderNo")String orderNo) {
		
		Map<String,Object> result  = new HashMap<String,Object>();
		try {
			logger.info("推送保权失败信息，传入参数：workid="+workid+",type="+type+",ctype="+ctype+",uid="+uid);
			pushService.copyrightFail(workid,uid,type,orderNo, result);
		} catch (Exception e) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE, YcContext.SYS_ERROR_MSG);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			logger.error(e);
		}
		return result;
	}
	
	
	@ResponseBody
	@RequestMapping(value="/demandExpire23", method = RequestMethod.POST, produces = "application/json")
	public Map<String,Object> demandExpire23(
			@RequestParam(value="uid") Long uid,
			@RequestParam(value="did") Long did) {
		
		Map<String,Object> result  = new HashMap<String,Object>();
		try {
			logger.info("推送合作将过期信息，传入参数：uid="+uid);
			pushService.demangExpire(uid, did,result);
		} catch (Exception e) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE, YcContext.SYS_ERROR_MSG);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			logger.error(e);
		}
		return result;
	}
}
